<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>项目新增</title>
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../js/formSelects/formSelects-v4.css" media="all">
    <link rel="stylesheet" href="../css/font/iconfont.css" media="all">

    <style>
        .other_name {
            display: inline-block;
            margin-right: 10px;
            cursor: pointer;
        }
        .other_name>i {
            margin-left: 5px;
        }
        .other_name>i:hover {
            color: #FFFFFF;
        }

        .layui-form-label{
            width:140px;
        }
        .layui-input-block{
            margin-left: 170px;
        }
        a{
            color:#fff;
        }
        a:hover {
            color: #00c0ef;
        }
    </style>
</head>
<body>


<div style="margin-top: 40px; margin-right: 30px;">
    <form class="layui-form" action=""  lay-filter="dataForm">



        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-block">
                <input type="text" name="projectname" id="projectname"  readonly class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">劳务公司名称</label>
            <div class="layui-input-block">
                <input type="hidden" id="licno" name="licno">
                <input type="text" name="companyname" id="companyname"readonly class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="display: none">
            <label class="layui-form-label"></label>
            <div class="layui-input-block" id="divOtherName">
            </div>
        </div>



        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>项目信息</legend>
        </fieldset>

        <div class="layui-form-item">
            <label class="layui-form-label">项目地址</label>
            <div class="layui-input-block">
                <input type="text" name="projectadress" id="projectadress" readonly lay-verify="required1" placeholder="项目地址" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">工程状态</label>
                <div class="layui-input-inline">
                    <input type="text" name="projectstatus" id="projectstatus" readonly lay-verify="required1"  class="layui-input">

                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">项目类型</label>
                <div class="layui-input-inline">
                    <input type="text" name="projecttype" id="projecttype" readonly lay-verify="required1"  class="layui-input">

                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color:red">*</span>项目负责人</label>
                <div class="layui-input-inline">
                    <input type="text" name="projectperson" id="projectperson" readonly lay-verify="required1" placeholder="项目负责人" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color:red">*</span>项目负责人电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="projectpersonphone" id="projectpersonphone" readonly lay-verify="required1|float" placeholder="项目负责人电话" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item" style="margin-top: 60px;">
            <div class="layui-input-block" style="text-align: center;">

            </div>
        </div>
        <div style="position: fixed;bottom:0px;height: 60px; text-align: center;background: #030B1E;left:0;right: 0;line-height: 60px;border-top:1px solid #02BFD9">
            <button  class="layui-btn" lay-filter="formSubmitPass"  lay-submit="">审批通过</button>
            <button  class="layui-btn layui-btn-danger" lay-filter="formSubmitNo"  lay-submit="">审批不通过</button>
        </div>

    </form>
</div>

</body>
<script src="../assets/layui/layui.js"></script>
<script src="../js/common.js"></script>
<script>
    layui.config({
        base: '../js/'
    }).extend({
        formSelects: 'formSelects/formSelects-v4'
    });
    var $;
    var houseData=[];
    layui.use(['jquery','form','validate','common','element', 'laydate','upload','formSelects'], function () {
        var form = layui.form,
            layer = layui.layer,
            validate = layui.validate,
            element=layui.element,
            laydate = layui.laydate,
            upload = layui.upload,
            formSelects = layui.formSelects,
            common = layui.common;
        $ = layui.jquery;

        validate.regVerify();

        var projectId=common.getUrlParam("id");
        var op=common.getUrlParam("op");


        $.ajax({
            url: "../project/info",
            dataType: "json",
            data: { projectId: projectId ,op:"1" },
            success: function (rtn) {
                if (rtn && rtn.code===0) {
                    var data = rtn.data;
                    form.val('dataForm', {
                        projectname: data.projectname
                        , projecttype: data.projecttype
                        , projectadress: data.projectadress
                        , projectstatus: data.projectstatus
                        , companyname: data.companyname
                        , projectperson: data.projectperson
                        , projectpersonphone: data.projectpersonphone
                    });
                    form.render();
                }
            }
        });

        form.on('submit(formSubmitPass)', function (data) {
            layer.confirm('您确定 该项目审核通过吗', function (index) {
                $.ajax({
                    type: 'post',
                    url: '../project/upstatus',
                    data: {projectId: projectId, status: 2},
                    success: function (rtn) {
                        if (rtn.code === 0) {  //数据保存成功
                            var msg = "提交成功，审核通过!";
                            common.showInfo(msg, function () {
                                //刷新前页
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.document.getElementById('btnSearch').click();
                                parent.layer.close(index);
                            });
                        }
                        else {
                            common.showError(rtn.msg);
                        }
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                        common.showError('保存错误');
                    }
                });
            });

            return false;
        });

        form.on('submit(formSubmitNo)', function (data) {
            layer.prompt({
                formType: 2,
                value: '请填写不通过原因',
                title: '您确定 该项目审核不通过吗',
                area: ['300px', '80px'] //自定义文本域宽高
            }, function (value, index, elem) {
                if (value == "" || value=="请填写不通过原因") {
                    common.showError("原因为空")
                } else {
                    $.ajax({
                        type: 'post',
                        url: '../project/upstatus',
                        data: {projectId: projectId, status: 3, reason: value},
                        success: function (rtn) {
                            if (rtn.code === 0) {  //数据保存成功
                                var msg = "提交成功，审核不通过!";
                                common.showInfo(msg, function () {
                                    //刷新前页
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.document.getElementById('btnSearch').click();
                                    parent.layer.close(index);
                                });
                            }
                            else {
                                common.showError(rtn.msg);
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            common.showError('保存错误');
                        }
                    });
                }
            });
            return false;
        });


    })


</script>
</html>